package com.fxl.majiang.room;

import com.fxl.majiang.enums.TilesEnum;
import com.fxl.majiang.enums.TilesGroupTypeEnum;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author fengxinglei
 * @date 2022/8/2 17:19
 * @description 牌组，比如吃碰胡
 */
@Data
@NoArgsConstructor
public class TilesGroup implements Serializable {

    private static final long serialVersionUID = -932139111086538958L;
    /**
     * 牌组类型
     * @see TilesGroupTypeEnum
     */
    private TilesGroupTypeEnum type;

    /**
     * 牌组
     */
    private List<TilesEnum> tiles;

    public TilesGroup(TilesGroupTypeEnum type, List<TilesEnum> tiles) {
        this.type = type;
        this.tiles = tiles;
    }

    public void addTile(TilesEnum tile) {
        if (tiles == null) {
            tiles = new ArrayList<>();
        }
        tiles.add(tile);
    }
}
